import Requset from './request/request'
import { BASE_URL, TIME_OUT } from './request/config'
import localCache from '@/utils/cache'
const request = new Requset({
  baseURL: BASE_URL,
  //  超时时间
  timeout: TIME_OUT,
  //  跨域是否带token
  // withCredentials: false,
  //  设置请求头
  // headers: TOKEN_HEADER,
  //  拦截器
  inerceptors: {
    requestInterceptor: (config) => {
      // 在发送请求之前做某件事
      const token = localCache.getCache('token')

      if (token && config.headers) {
        config.headers.Authorization = `Bearer ${token}`
      }
      return config
    },
    requestErrorInterceptor: (error) => {
      //  对请求错误做某件事
      return error
    },
    responseInterceptor: (response) => {
      //  console.log('拦截响应数据', response)
      // 对响应数据做某件事
      return response
    },
    responseErrorInterceptor(error) {
      // 对响应错误做某件事
      console.log('responseErrorInterceptor', error)
      return error
    }
  }
})
export default request

// import { getToken } from './utils/auth'
// import { getStore } from './utils/storage'
// import { getUserInfo } from './utils/user'
// import { getUserId } from './utils/user'
// import { getUserName } from './utils/user'
// import { getUserPhone } from './utils/user'
// import { getUserAvatar } from './utils/user'
// import { getUserGender } from './utils/user'
// import { getUserBirthday } from './utils/user'
// import { getUserAddress } from './utils/user'
// import { getUserSignature } from './utils/user'
// import { getUserToken } from './utils/user'
// import { getUserTokenExpire } from './utils/user'
// import { getUserTokenRefresh } from './utils/user'
// import { getUserTokenRefreshExpire } from './utils/user'
// import { getUserTokenRefreshTime } from './utils/user'
// import { getUserTokenTime } from './utils/user'
// import { getUserTokenExpireTime } from './utils/user'
// import { getUserTokenRefreshExpireTime } from './utils/user'
// import { getUserTokenRefreshTimeTime } from './utils/user'
// import { getUserTokenTimeTime } from './utils/user'
// import { getUserTokenExpireTimeTime } from './utils/user'
// import { getUserTokenRefreshExpireTimeTime } from './utils/user'
// import { getUserTokenRefreshTimeTimeTime } from './utils/user'
